﻿package main 
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	
	/**
	 * 舵
	 * @author kimura
	 */
	public class Helm {
		
		[Embed(source = '../../lib/Fin02.png')]
		private static const HelmImage:Class;
		
		public function Helm() {
			sprite = new Sprite();
			var bmp:Bitmap = new HelmImage();
			bmp.scaleX = bmp.scaleY = 0.25;
			bmp.x = 0;
			bmp.y = -bmp.height / 2;
			sprite.addChild(bmp);
			setAngle(0);
		}
		
		private var sprite:Sprite;
		public function getSprite():Sprite {
			return sprite;
		}
		
		public function getAngle():Number {
			return -sprite.scaleX * 20;
		}
		public function setAngle(angle:Number):void {
			if (angle > 20) {
				angle = 20;
			} else if (angle < -20) {
				angle = -20;
			}
			sprite.scaleX = -angle / 20;
		}
	}
	
}